<?php
namespace app\qrcode\controller;

use tp5_lib\common\controller\BaseController;
use QRcode;
use QrReader;

class IndexController extends BaseController
{
    public function index()
    {
        return $this->fetch();
    }
    public function encode()
    {
        $content=input("content","hello world");
        require_once '../extend/phpqrcode.php';
        header("Content-type: image/png");
        QRcode::png($content);
    }
    public function decode()
    {
        $img=$_FILES["img"];
        require_once '../extend/qr_reader/QrReader.php';
        $qrcode = new QrReader($img["tmp_name"]);
        $text = $qrcode->text();
        echo $text;
    }
}
